package com.zxj.geekstudy.controller;

import com.zxj.geekstudy.dao.StudentDao;
import com.zxj.geekstudy.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(path = "student")
public class StudentController {
    @Autowired
    private StudentDao studentDao;

    @RequestMapping(path = "create", method = {RequestMethod.GET})
    public String create(Student student) {
        studentDao.create(student);
        return "success";
    }

    @RequestMapping(path = "list", method = {RequestMethod.GET})
    public List<Student> list() {
        return studentDao.list();
    }
}
